﻿using HardcoreGame.Content.Items.Weapons.Summon.Sentries;
using HardcoreGame.Content.Items.Weapons.Summon.Whips;
using System.Linq;
using Terraria;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;

namespace HardcoreGame.Common.GlobalNPCs
{
    public class LootNPC : GlobalNPC
    {
        public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
        {
            if (npc.type == NPCID.DD2Betsy)
            {
                foreach (var rule in npcLoot.Get())
                {
                    if (rule is DropBasedOnExpertMode dropBasedOnExpertMode && dropBasedOnExpertMode.ruleForNormalMode is OneFromOptionsNotScaledWithLuckDropRule oneFromOptionsDrop && oneFromOptionsDrop.dropIds.Contains(3870))
                    {
                        var original = oneFromOptionsDrop.dropIds.ToList();
                        original.Add(ModContent.ItemType<AirAlert>());
                        oneFromOptionsDrop.dropIds = [.. original];
                    }
                }
            }
            if (npc.type == NPCID.SkeletonSniper)
            {
                npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<BrokenSkull>(), 12, 1, 1));
            }
        }
    }
}
